var a = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../utils/util.js")), t = getApp();

Page({
    data: {
        city: "",
        page: 1,
        keywords: ""
    },
    onLoad: function(a) {
        console.log(a), this.setData({
            city_name: a.city_name,
            city: a.city_name,
            keywords: a.keywords
        }), this.infrom();
    },
    goDw: function(a) {
        wx.navigateTo({
            url: "/packageC/o2o/o2oLocation/o2oLocation?tag=activitySearch"
        });
    },
    inpText: function(a) {
        this.setData({
            inpText: a.detail.value
        });
    },
    goSearch: function(a) {
        this.setData({
            page: 1
        }), this.data.inpText || this.setData({
            inpText: ""
        }), this.infrom();
    },
    goxq: function(a) {
        var t = a.currentTarget.id;
        a.currentTarget.id && wx.navigateTo({
            url: "/packageC/Myshaky/enrollEnter/enrollEnter?id=" + t
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.current_page < this.data.last_page ? (this.setData({
            page: this.data.page + 1
        }), wx.showLoading({
            title: "加载中",
            mask: !0
        }), this.nextinfrom()) : wx.showToast({
            title: "没有更多",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    nextinfrom: function() {
        var e = t.getNetAddresss("plugin.activity-apply.api.index.getSearch"), n = this;
        t._getNetWork({
            url: e,
            data: {
                city_name: n.data.city_name,
                keywords: n.data.keywords,
                page: n.data.page
            },
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    console.log(e), 0 == e.data.data.length ? n.setData({
                        kong: !0
                    }) : n.setData({
                        kong: !1
                    });
                    for (var o = 0; o < e.data.data.length; o++) e.data.data[o].start_time = a.default.formatTimeTwo(e.data.data[o].start_time, "Y/M/D h:m:s");
                    if (e.data.current_page >= e.data.last_page) return wx.hideToast(), wx.showToast({
                        title: "没有更多",
                        icon: "none"
                    }), void n.setData({
                        current_page: e.data.current_page,
                        last_page: e.data.last_page
                    });
                    wx.hideToast(), n.setData({
                        listData: n.data.listData.concat(e.data.data),
                        current_page: e.data.current_page,
                        last_page: e.data.last_page
                    });
                }
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    infrom: function() {
        var e = t.getNetAddresss("plugin.activity-apply.api.index.getSearch"), n = this;
        t._getNetWork({
            url: e,
            data: {
                city_name: n.data.city_name,
                keywords: n.data.keywords,
                page: n.data.page
            },
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    console.log(e), 0 == e.data.data.length ? n.setData({
                        kong: !0
                    }) : n.setData({
                        kong: !1
                    });
                    for (var o = Date.parse(new Date()) / 1e3, i = 0; i < e.data.data.length; i++) e.data.data[i].start_time = a.default.formatTimeTwo(e.data.data[i].start_time, "Y/M/D h:m:s");
                    n.setData({
                        listData: e.data.data,
                        nowTime: o,
                        current_page: e.data.current_page,
                        last_page: e.data.last_page
                    });
                }
            },
            fail: function(a) {
                console.log(a);
            }
        });
    }
});